import request from '@/config/axios'

export interface MemberVO {
  id: string
  nickname: string
  avatar: string
  status: number
  mobile: string
  loginDate: number
  updateTime: number
}

export type MemberPageVO = MemberVO & {
  inviterMemberId: string
  inviterNickname: string
  inviterAvatar: string
}

export type MemberDetailVO = MemberVO & {
  createTime: number
  openId: string
  unionId: string
  inviterMember: string
}

export type MemberDTO = Partial<MemberVO>

// 查询用户列表
export const getMemberPage = async (params) => {
  return await request.get({ url: `/member/user/page`, params })
}

// 查询用户详情
export const getMember = async (id: string) => {
  return await request.get({ url: `/member/user/get?id=` + id })
}

// 新增用户
export const createMember = async (data: MemberVO) => {
  return await request.post({ url: `/member/user/create`, data })
}

// 修改用户
export const updateMember = async (data: MemberVO) => {
  return await request.put({ url: `/member/user/update`, data })
}

// 删除用户
export const deleteMember = async (id: string) => {
  return await request.delete({ url: `/member/user/delete?id=` + id })
}

// 导出用户 Excel
export const exportMember = async (params) => {
  return await request.download({ url: `/member/user/export-excel`, params })
}
